package com.bwie.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.mapper.GoMapper;
import com.bwie.pojo.Go;
import com.bwie.pojo.Order;
import com.bwie.service.OrderService;
import com.bwie.mapper.OrderMapper;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author 24026
* @description 针对表【t_order】的数据库操作Service实现
* @createDate 2025-08-28 09:43:30
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
    implements OrderService{

    @Autowired
    OrderMapper orderMapper;
    @Autowired
    GoMapper goMapper;
    @Override
    public R getOrderList(PageInfoVo pageInfoVo) {
        Page<Order> page = new Page<>(pageInfoVo.getPageNum(), pageInfoVo.getPageSize());
        Page<Order> orderPage =  orderMapper.getOrderList(page,pageInfoVo);
        return R.OK(orderPage);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public R addList(Order order) {

        Go go = new Go();
        go.setGoName(order.getOrderName());
        go.setGoNum(order.getOrderNum());
        go.setGoPrice(order.getOrderPrice());
        goMapper.insert(go);
        return R.OK();
    }

    @Override
    public R getGoList(PageInfoVo pageInfoVo) {
        List<Go> gos = goMapper.selectList(null);
        return R.OK(gos);
    }
}




